<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>单体模式</title>
</head>
<body>
<script>
    var Singleton={
        attribute1:true,
        attribute2:10,
        method1:function(){

        },
        method2zx:function(){

        }
    }
    Singleton.attribute1=false;
    //a=15;
    //var a=122;
    function s(){
        a=15;
    }
    console.log(window.a);//undefined
   // console.log(a);//报错  a is not defined
//把网页专用的放在这个里面

    Namespace.PageName={
        _CONSTANT_1:true,
        _CONTANT_2:10,
        _methods1:function(){
        },
        //public method:
        stringToArray:function(){

        }
    }
    MyNamespace.PageName=function (){
        //private
        var private1=true;
        var private2=10;
        function methods1(){

        };
        function methods2(){

        }
        return{
            methods1:function(){

            },
            methods2:function(){

            }
        }
    }
</script>
</body>
</html>